#!/usr/bin/python
#encoding=utf-8
import time

def tcp_alarm_content(websitename,tcp_port,url):
	'''
	@故障信息，页面访问失败
	'''
	monitorTime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
	
	topTemp = "乾冠网站监测服务平台监控到您的:"+str(websitename)+" TCP端口存在异常。\n "
	bottomTemp = "故障原因:TCP端口%s失败"%(tcp_port)
	subject = "[故障信息]"+str(topTemp)
		
	middleTemp = "监控类型:TCP \n\
			所在域/服务器:"+str(url)+" \n\
			检查时间:"+str(monitorTime)+" \n "
	template = topTemp + middleTemp + bottomTemp
	return subject,template	
		
def udp_alarm_content(websitename,udp_port,url):
	'''
	@故障信息，页面访问失败
	'''
	monitorTime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
	
	topTemp = "乾冠网站监测服务平台监控到您的:"+str(websitename)+" UDP端口存在异常。\n "
	bottomTemp = "故障原因:UDP端口%s失败"%(udp_port)
	subject = "[故障信息]"+str(topTemp)
		
	middleTemp = "监控类型:UDP \n\
			所在域/服务器:"+str(url)+" \n\
			检查时间:"+str(monitorTime)+" \n "
	template = topTemp + middleTemp + bottomTemp
	return template,subject
	

def vul_alarm_content(websitename,vul,url):
	'''
	@故障信息，页面访问失败
	'''
	monitorTime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
	
	topTemp = "乾冠网站监测服务平台监控到您的:"+str(websitename)+" 存在高危漏洞。\n "
	bottomTemp = "报警原因:高危漏洞,%s,%s"%(vul,url)
	subject = "[故障信息]"+str(topTemp)
		
	middleTemp = "监控类型:漏洞监测 \n\
			所在域/服务器:"+str(url)+" \n\
			检查时间:"+str(monitorTime)+" \n "
	template = topTemp + middleTemp + bottomTemp
	return subject,template	
	

def tamper_alarm_content(websitename,tamper,url):
	'''
	@故障信息，页面篡改
	'''
	monitorTime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
	
	topTemp = "乾冠网站监测服务平台监控到您的:"+str(websitename)+" 。\n "
	bottomTemp = "故障原因:%s"%(tamper,)
	subject = "[故障信息]"+str(topTemp)
		
	middleTemp = "监控类型: 页面篡改\n\
			所在域/服务器:"+str(url)+" \n\
			检查时间:"+str(monitorTime)+" \n "
	template = topTemp + middleTemp + bottomTemp
	return subject,template	

def senword_alarm_content(websitename,senword,url):
	'''
	@故障信息，页面篡改
	'''
	monitorTime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
	
	topTemp = "乾冠网站监测服务平台监控到您的:"+str(websitename)+"  存在敏感词语。\n "
	bottomTemp = "故障原因:%s"%(senword,)
	subject = "[故障信息]"+str(topTemp)
		
	middleTemp = "监控类型: 敏感词\n\
			所在域/服务器:"+str(url)+" \n\
			检查时间:"+str(monitorTime)+" \n "
	template = topTemp + middleTemp + bottomTemp
	return subject,template